package routers

import (
	"github.com/astaxie/beego"
	"github.com/astaxie/beego/plugins/cors"
	"wego/controllers"
)

func init() {
	beego.InsertFilter("*", beego.BeforeRouter, cors.Allow(&cors.Options{
		AllowAllOrigins: true,
		//AllowOrigins:      []string{"https://192.168.0.102"},
		AllowMethods:     []string{"GET", "POST", "PUT", "DELETE", "OPTIONS"},
		AllowHeaders:     []string{"Origin", "Authorization", "Access-Control-Allow-Origin", "Access-Control-Allow-Headers", "Content-Type"},
		ExposeHeaders:    []string{"Content-Length", "Access-Control-Allow-Origin", "Access-Control-Allow-Headers", "Content-Type"},
		AllowCredentials: true,
	}))
	beego.Router("/", &controllers.MainController{}, "get:Index")

	beego.Router("/admin/login/login", &controllers.LoginController{}, "post:Login")
	beego.Router("/admin/login/logout", &controllers.LoginController{}, "post:Logout")

	beego.Router("/admin/system/site", &controllers.SystemController{}, "post:Site")
	beego.Router("/admin/system/sitesave", &controllers.SystemController{}, "post:SiteSave")

	beego.Router("/admin/upload/getqiniutoken", &controllers.UploadController{}, "post:GetQiniuToken")
	beego.Router("/admin/upload/getattach", &controllers.UploadController{}, "post:GetAttach")
	beego.Router("/admin/upload/gettype", &controllers.UploadController{}, "post:GetType")
	beego.Router("/admin/upload/moveattachtotype", &controllers.UploadController{}, "post:MoveAttachToType")
	beego.Router("/admin/upload/delattach", &controllers.UploadController{}, "post:DelAttach")
	beego.Router("/admin/upload/savetype", &controllers.UploadController{}, "post:SaveType")
	beego.Router("/admin/upload/deltype", &controllers.UploadController{}, "post:DelType")
	beego.Router("/admin/upload/qiniuupload", &controllers.UploadController{}, "post:QiniuUpload")
	beego.Router("/admin/upload/doupload", &controllers.UploadController{}, "post:DoUpload")

	beego.Router("/admin/admin/adminlist", &controllers.AdminController{}, "post:AdminList")
	beego.Router("/admin/admin/getadmin", &controllers.AdminController{}, "post:GetAdminByGroupId")
	beego.Router("/admin/admin/adminsave", &controllers.AdminController{}, "post:AdminSave")
	beego.Router("/admin/admin/adminstatus", &controllers.AdminController{}, "post:AdminStatus")
	beego.Router("/admin/admin/admindel", &controllers.AdminController{}, "post:AdminDel")

	beego.Router("/admin/menu/menulist", &controllers.MenuController{}, "post:MenuList")
	beego.Router("/admin/menu/menusave", &controllers.MenuController{}, "post:MenuSave")
	beego.Router("/admin/menu/menustatus", &controllers.MenuController{}, "post:MenuStatus")
	beego.Router("/admin/menu/menudel", &controllers.MenuController{}, "post:MenuDel")

	beego.Router("/admin/auth/authlist", &controllers.AuthController{}, "post:AuthList")
	beego.Router("/admin/auth/authsave", &controllers.AuthController{}, "post:AuthSave")
	beego.Router("/admin/auth/authstatus", &controllers.AuthController{}, "post:AuthStatus")
	beego.Router("/admin/auth/authdel", &controllers.AuthController{}, "post:AuthDel")
	beego.Router("/admin/auth/memberdel", &controllers.AuthController{}, "post:MemberDel")
	beego.Router("/admin/auth/rulelist", &controllers.AuthController{}, "post:RuleList")

}
